package jt.classic.app.wjcsgl.wjcs;

import jt.classic.app.util.ListRange;

import jt.classic.system.ISystem;
import jt.classic.system.SimpleAction;
import jt.classic.system.database.SystemDataSource;
import jt.classic.system.user.IUser;
import jt.classic.system.user.UserManager;

import net.sf.json.JSONObject;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import org.limp.basework.console.XSystemConsole;
import org.limp.basework.console.XSystemConsoleRunException;
import org.limp.basework.impl.CommonBean4HSQ;

import org.limp.mine.Controller;
import org.limp.mine.DataTrimmer;
import org.limp.mine.DataTrimmerI;
import org.limp.mine.DataTrimmerI.DataItemList;
import org.limp.mine.Label;
import org.limp.mine.QueryJack;
import org.limp.mine.QueryJackFactory;
import org.limp.mine.StringTool;

import java.sql.Connection;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * ��~
 * @author zhuhj
 */
public class WjcsAction extends SimpleAction {
    /**
     * �½���~
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward neu(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        return mapping.findForward("neu");
    }

    /**
     * ����ģ�鶨��
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward save(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();

            //console.RUN2SAVE(request, conn);
            console.RUN2REMIX(request, conn);
            conn.commit();

            //String url = "/wjcs.do?method=list";
            String url = "/wjcs.do?method=list4query";
            forward = new ActionForward();
            forward.setPath(url);
            forward.setRedirect(true);
        } catch (XSystemConsoleRunException ex) {
            conn.rollback();
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 查阅接收文件
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     * @throws Exception
     */
    public ActionForward read(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String id = (String) param.get("id");

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            String sql =
                "UPDATE APP_WJJS SET WJJS_STATUS = '已接收' WHERE WJJSR_ID = '" +
                user.id() + "' AND WJFSBID = ?";

            DataTrimmerI trimmer = new DataTrimmerI(conn);

            DataItemList dil = trimmer.createDIL();

            dil.set(id);

            trimmer.execute(sql, dil);

            conn.commit();

            request.setAttribute("result", "{success:true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success:false}");
            conn.rollback();
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * �༭��~��Ϣ
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */

    /*public ActionForward edit(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            ClxxManager manager = new ClxxManager(conn);

            Map clxx = manager.getclxxById(id);

            request.setAttribute("clxx", clxx);

            forward = mapping.findForward("edit");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }*/

    /**
     * �༭��~��Ϣ
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */

    /*public ActionForward view(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            ClxxManager manager = new ClxxManager(conn);

            Map clxx = manager.getclxxById(id);

            request.setAttribute("clxx", clxx);

            forward = mapping.findForward("view");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }*/

    /**
     * �޸ĳ�~��Ϣ
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */

    /*public ActionForward update(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;
        String id = StringTool.checkString(request.getParameter("clxx_id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();
            console.RUN2UPDATE(request, conn);

            conn.commit();

            String url = "/clxx.do?method=edit&id=" + id;

            forward = new ActionForward();
            forward.setPath(url);
            forward.setRedirect(true);
        } catch (XSystemConsoleRunException ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }*/

    /**
     * ��~��Դ�����б�
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward list(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String index = StringTool.checkString(param.get("index"));
        request.setAttribute("index", index);

        String type = StringTool.checkString(param.get("type")); //ҳ������ select

        String v_clxx_pzh = StringTool.checkString(param.get("v_clxx_pzh"));

        request.setAttribute("v_clxx_pzh", v_clxx_pzh);

        String v_clxx_cp = StringTool.checkString(param.get("v_clxx_cp"));

        request.setAttribute("v_clxx_cp", v_clxx_cp);

        IUser user = ISystem.getSessionUser(request);

        StringBuffer where = new StringBuffer(" WHERE 1=1 ");

        if (ISystem.isAdmin(user)) {
            //donothing
        } else if (ISystem.matchrole(user, "hysadmin")) {
            //            if (user.igroup() != null) {
            //                String gid = user.igroup().ibranchgroup(0);
            //
            //                where.append(" AND HYS_GSID_NAME = '" + gid + "' ");
            //            }
        }

        if (!v_clxx_pzh.equals("")) {
            where.append(" AND clxx_pzh LIKE '%" + v_clxx_pzh + "%' ");
        }

        if (!v_clxx_cp.equals("")) {
            where.append(" AND clxx_cp LIKE '%" + v_clxx_cp + "%' ");
        }

        String sql1 = "SELECT COUNT(1) FROM APP_CLXX " + where.toString();
        String sql2 = "SELECT * FROM APP_CLXX " + where.toString() +
            " ORDER BY CLXX_ID ASC";

        // ת��
        String forward = "list";
        String url = "";
        url = request.getContextPath() + "/app/clxx.do?method=list";

        if (type == "") { //�б�ҳ��
            url = request.getContextPath() + "/app/clxx.do?method=list";
            forward = "list";
        } else if (type.equals("select")) { //ѡ��ҳ��
            url = request.getContextPath() +
                "/app/clxx.do?method=list&type=select&index=" + index;
            forward = "list_select";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // ����
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            /**
            if (!resultList.isEmpty()) {
                ModuleManager manager = new ModuleManager(conn);

                for (int i = 0; i < resultList.size(); i++) {
                    String id = (String) ((Map) resultList.get(i)).get("ID");
                    IModule module = manager.getModuleById(id);
                    ((Map) resultList.get(i)).put("module", module);
                }
            }
                        */

            // �����ת����
            Controller controller = plus.getController("form1");

            // ���õ�ת����
            controller.setType("input");

            // ��ʾ��ǩ
            Label label = plus.getLabel();

            // ������ʾ��ǩ����
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward(forward);
    }

    /**
     * ��~��Դ�鿴�б�
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward list4query(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String wjjsr_name = StringTool.checkString(param.get("wjjsr_name"));

        request.setAttribute("wjjsr_name", wjjsr_name);

        String wj_name = StringTool.checkString(param.get("wj_name"));

        request.setAttribute("wj_name", wj_name);

        IUser user = ISystem.getSessionUser(request);

        StringBuffer where = new StringBuffer(
                " WHERE WJCS.ID = ANNEX.FK_ANNEX_ID AND ANNEX.ANNEX_OBJECT = 'APP_WJCS' ");

        where.append(" AND WJCS.USERID = '" + user.id() + "' ");

        if (!wjjsr_name.equals("")) {
            where.append(
                " AND WJCS.ID IN (SELECT WJFSBID FROM APP_WJJS WHERE APP_WJJS.WJJSR_NAME LIKE '%" +
                wjjsr_name + "%') ");
        }

        if (!wj_name.equals("")) {
            where.append(" AND ANNEX.ANNEX_NAME LIKE '%" + wj_name + "%' ");
        }

        String sql1 =
            "SELECT COUNT(WJCS.ID) FROM APP_WJCS WJCS,XSYSTEM_ANNEX ANNEX" +
            where.toString();
        String sql2 =
            "SELECT WJCS.*,ANNEX.XSYSTEM_ANNEX_ID,ANNEX.ANNEX_NAME FROM APP_WJCS WJCS,XSYSTEM_ANNEX ANNEX " +
            where.toString() + " ORDER BY SEND_TIME DESC";

        //" ORDER BY  WJJS.WJTIME ASC";
        String url = request.getContextPath() +
            "/app/wjcs.do?method=list4query";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // ����
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            /**
            if (!resultList.isEmpty()) {
                ModuleManager manager = new ModuleManager(conn);

                for (int i = 0; i < resultList.size(); i++) {
                    String id = (String) ((Map) resultList.get(i)).get("ID");
                    IModule module = manager.getModuleById(id);
                    ((Map) resultList.get(i)).put("module", module);
                }
            }
                        */

            // �����ת����
            Controller controller = plus.getController("form1");

            // ���õ�ת����
            controller.setType("input");

            // ��ʾ��ǩ
            Label label = plus.getLabel();

            // ������ʾ��ǩ����
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("list4query");
    }

    /**
     * 我的文件接收列表
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward list4query_js(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String wjfsr_name = StringTool.checkString(param.get("wjfsr_name"));

        request.setAttribute("wjfsr_name", wjfsr_name);

        String wj_name = StringTool.checkString(param.get("wj_name"));

        request.setAttribute("wj_name", wj_name);

        IUser user = ISystem.getSessionUser(request);

        StringBuffer where = new StringBuffer();

        if (!wjfsr_name.equals("")) {
            where.append(" AND APP_WJCS.USERNAME LIKE '%" + wjfsr_name + "%' ");
        }

        if (!wj_name.equals("")) {
            where.append(" AND XSYSTEM_ANNEX.ANNEX_NAME LIKE '%" + wj_name +
                "%' ");
        }

        String flumeid = UserManager.iallgroupflumeid(user.iallgroupflumeid(","));

        StringBuffer wherein = new StringBuffer(
                "SELECT WJFSBID FROM APP_WJJS WHERE (WJJSR_ID = '" + user.id() +
                "' AND WJJSR_TYPE = 'user') OR (WJJSR_ID IN (" + flumeid +
                ") AND WJJSR_TYPE = 'group') GROUP BY WJFSBID");

        String sql1 = "SELECT COUNT(APP_WJCS.ID) FROM APP_WJCS, (" +
            wherein.toString() +
            ") A,XSYSTEM_ANNEX  WHERE APP_WJCS.ID = A.WJFSBID AND XSYSTEM_ANNEX.ANNEX_OBJECT = 'APP_WJCS' AND XSYSTEM_ANNEX.FK_ANNEX_ID = APP_WJCS.ID " +
            where.toString();
        String sql2 =
            "SELECT XSYSTEM_ANNEX.XSYSTEM_ANNEX_ID,XSYSTEM_ANNEX.ANNEX_NAME,APP_WJCS.* FROM APP_WJCS, (" +
            wherein.toString() +
            ") A,XSYSTEM_ANNEX  WHERE APP_WJCS.ID = A.WJFSBID AND XSYSTEM_ANNEX.ANNEX_OBJECT = 'APP_WJCS' AND XSYSTEM_ANNEX.FK_ANNEX_ID = APP_WJCS.ID " +
            where.toString() + " ORDER BY SEND_TIME DESC";

        //" ORDER BY  WJJS.WJTIME ASC";
        String url = request.getContextPath() +
            "/app/wjcs.do?method=list4query";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // ����
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            /**
            if (!resultList.isEmpty()) {
                ModuleManager manager = new ModuleManager(conn);

                for (int i = 0; i < resultList.size(); i++) {
                    String id = (String) ((Map) resultList.get(i)).get("ID");
                    IModule module = manager.getModuleById(id);
                    ((Map) resultList.get(i)).put("module", module);
                }
            }
                        */

            // �����ת����
            Controller controller = plus.getController("form1");

            // ���õ�ת����
            controller.setType("input");

            // ��ʾ��ǩ
            Label label = plus.getLabel();

            // ������ʾ��ǩ����
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("list4query_js");
    }

    /**
     * 我的文件接收列表(json)
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward jslist4json(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String _size = StringTool.checkString(param.get("size"));

        int size = 10;

        if (!_size.equals("")) {
            size = Integer.parseInt(_size);
        }

        IUser user = ISystem.getSessionUser(request);

        String flumeid = UserManager.iallgroupflumeid(user.iallgroupflumeid(","));

        StringBuffer wherein = new StringBuffer(
                "SELECT WJFSBID FROM APP_WJJS WHERE (WJJSR_ID = '" + user.id() +
                "' AND WJJSR_TYPE = 'user') OR (WJJSR_ID IN (" + flumeid +
                ") AND WJJSR_TYPE = 'group') GROUP BY WJFSBID");

        String sql =
            "SELECT XSYSTEM_ANNEX.XSYSTEM_ANNEX_ID,XSYSTEM_ANNEX.ANNEX_NAME,APP_WJCS.* FROM APP_WJCS, (" +
            wherein.toString() +
            ") A,XSYSTEM_ANNEX  WHERE APP_WJCS.ID = A.WJFSBID AND XSYSTEM_ANNEX.ANNEX_OBJECT = 'APP_WJCS' " +
            "AND XSYSTEM_ANNEX.FK_ANNEX_ID = APP_WJCS.ID ORDER BY SEND_TIME DESC";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            DataTrimmer trimmer = new DataTrimmer(conn);

            List list = trimmer.searchMultiData(sql, size);

            ListRange lr = new ListRange();
            lr.setTotalSize(list.size());
            lr.setList(list);
            lr.setSuccess(true);

            request.setAttribute("result", JSONObject.fromObject(lr).toString());
        } catch (Exception ex) {
            request.setAttribute("result",
                JSONObject.fromObject(new ListRange()).toString());
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 文件接收人列表(json)
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward queryjsr(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String id = StringTool.checkString(param.get("id"));

        IUser user = ISystem.getSessionUser(request);

        String sql = "SELECT APP_WJJS.* FROM APP_WJJS WHERE WJFSBID = '" + id +
            "' ORDER BY WJJSR_NAME ASC";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            DataTrimmer trimmer = new DataTrimmer(conn);

            List list = trimmer.searchMultiData(sql);

            ListRange lr = new ListRange();
            lr.setTotalSize(list.size());
            lr.setList(list);
            lr.setSuccess(true);

            request.setAttribute("result", JSONObject.fromObject(lr).toString());
        } catch (Exception ex) {
            request.setAttribute("result",
                JSONObject.fromObject(new ListRange()).toString());
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * ��~��Դ�鿴
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward query(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        IUser user = ISystem.getSessionUser(request);

        StringBuffer where = new StringBuffer(" WHERE 1=1 ");

        if (ISystem.isAdmin(user)) {
            //donothing
        } else if (ISystem.matchrole(user, "hysadmin")) {
            if (user.igroup() != null) {
                String gname = user.igroup().ibranchgroup(0);
                where.append(" AND HYS_GSID_NAME = '" + gname + "' ");
            } else {
                where.append(" AND HYS_GSID_NAME = 'noname' ");
            }
        } else {
            where.append(" AND CREATE_USER = " + user.id() + " ");
        }

        String sql1 = "SELECT COUNT(CLXX_ID) FROM APP_CLXX " +
            where.toString();
        String sql2 = "SELECT * FROM APP_CLXX " + where.toString() +
            " ORDER BY CLXX_ID ASC";

        String url = request.getContextPath() + "/app/clxx.do?method=query";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // ����
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            /**
            if (!resultList.isEmpty()) {
                ModuleManager manager = new ModuleManager(conn);

                for (int i = 0; i < resultList.size(); i++) {
                    String id = (String) ((Map) resultList.get(i)).get("ID");
                    IModule module = manager.getModuleById(id);
                    ((Map) resultList.get(i)).put("module", module);
                }
            }
                        */

            // �����ת����
            Controller controller = plus.getController("form1");

            // ���õ�ת����
            controller.setType("input");

            // ��ʾ��ǩ
            Label label = plus.getLabel();

            // ������ʾ��ǩ����
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("query");
    }

    /**
     * ɾ��~������ɾ��
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */

    /*public ActionForward delete(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String ids = StringTool.checkString(request.getParameter("ids"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            ClxxManager manager = new ClxxManager(conn);

            manager.deleteS(ids);

            conn.commit();

            forward = mapping.findForward("delete");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }*/
}
